package cn.hl.sfzy.service.impl;

import cn.hl.sfzy.entity.Article;
import cn.hl.sfzy.entity.Systemuser;
import cn.hl.sfzy.entity.User;
import cn.hl.sfzy.mapper.UserMapper;
import cn.hl.sfzy.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName UserServiceImpl
 * @Description TOOO
 * @Author Lilysi
 * @Date 2024//10//24//11:46
 * @Version 1.0
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public int delete(Long id) {
        int delete = userMapper.delete(id);
        return delete;
    }

    @Override
    public int update(User user) {
        int update = userMapper.update(user);
        return update;
    }

    @Override
    public int insert(User user) {
        int insert = userMapper.insert(user);
        return insert;
    }

    @Override
    public User getUser(User user) {
        String username=user.getUsername();

        String password=user.getPassword();
        User users = userMapper.selectByUsernameAndPassword(username, password);
        return users;



    }

    @Override
    public PageInfo<User> findByPage(int pageNum, int pageSize, User user) {
        PageHelper.startPage(pageNum, pageSize);
        PageInfo<User> userPageInfo = new PageInfo<>(userMapper.select(user));
        return userPageInfo;
    }

    @Override
    public List<User> findAll() {
        List<User> users = userMapper.selectAll();
        return users;
    }

    @Override
    public User selectById(Long id) {
        return userMapper.selectById(id);
    }

    @Override
    public List<User> findAll(User user) {
        return userMapper.select(new User());
    }
}
